<?php
$name = $_POST['name'];
$pwd = $_POST['pwd'];

$db = new PDO('mysql:host=localhost;dbname=test', 'root', 'root');
$name = $db -> quote( $name );
$pwd = $db -> quote( $pwd );

$sql = "select * from user where name = $name and pwd = $pwd";

$res = $db -> query($sql);

if( $res )
{
   $arr['code'] = 0;
   $arr['msg'] = '登录成功';
   $arr['data'] = ''; 
}else{
    $arr['code'] = 1;
    $arr['msg'] = '账号或密码错误!!!';
    $arr['data'] = '';
}
    echo json_encode( $arr );      


?>